package com.learn.micro_mall.service.api.member.impl;

import com.learn.micro_mall.domain.entity.member.MemberLevelConfigurationEntity;
import com.learn.micro_mall.repository.member.MemberLevelRepository;
import com.learn.micro_mall.service.api.member.MemberLevelService;
import com.learn.micro_mall.service.convertor.member.MemberMapper;
import com.learn.micro_mall.service.request.member.MemberLevelConfigurationCreateRequest;
import com.learn.micro_mall.service.response.member.MemberLevelConfigurationCreateResponse;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/member")
public class MemberLevelServiceImpl implements MemberLevelService {

    @Resource
    private MemberLevelRepository memberLevelRepository;

    @Override
    @RequestMapping("/create")
    public MemberLevelConfigurationCreateResponse create(MemberLevelConfigurationCreateRequest request) throws Exception {
        MemberLevelConfigurationEntity memberLevelConfigurationEntity = MemberMapper.INSTANCES.toMemberLevelConfigurationEntity(request);
        memberLevelConfigurationEntity.valid();
        memberLevelRepository.insert(memberLevelConfigurationEntity);
        return null;
    }
}
